
package org.openeai.lite.common.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class DateTimeUtils
{

    private static final String DT_FORMAT_DEFAULT = "yyyy-MM-dd HH:mm:ss";

    private static final String DT_FORMAT_NICE = "dd-MM-yyyy, HH:mm";

    private static SimpleDateFormat sdf = new SimpleDateFormat(DT_FORMAT_DEFAULT);

    public static String now()
    {
        Calendar cal = Calendar.getInstance();
        return sdf.format(cal.getTime());
    }

    public Date millisToRawDate(Long millis)
    {
        return new Date(millis);
    }

    public String millisToFormattedDate(Long millis)
    {
        SimpleDateFormat sdf = new SimpleDateFormat(DT_FORMAT_NICE);
        return sdf.format(new Date(millis));
    }

    public Date currentDate()
    {
        return Calendar.getInstance().getTime();
    }

    public String currentDateString()
    {
        SimpleDateFormat sdf = new SimpleDateFormat(DT_FORMAT_NICE);
        return sdf.format(currentDate());
    }

    public Long currentDateMillis()
    {
        return Calendar.getInstance().getTimeInMillis();
    }

}
